package core

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"server/config"
	"server/middleware"
	"server/router"
)

/*
路由模块初始化
*/

func initRouters() *gin.Engine {
	var Router = gin.Default()
	Router.StaticFS(config.GlobalConf.Local.Path, http.Dir(config.GlobalConf.Local.Path)) // 为用户头像和文件提供静态地址
	// Router.Use(middleware.LoadTls())
	// 跨域
	//Router.Use(middleware.Cors())

	//基础路由
	PublicGroup := Router.Group("")
	{
		router.InitBaseRouter(PublicGroup)
	}

	//认证路由
	PrivateGroup := Router.Group("")
	PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
	{

		router.InitJwtRouter(PrivateGroup)    // jwt相关路由
		router.InitUserRouter(PrivateGroup)   // 注册用户路由
		router.InitCasbinRouter(PrivateGroup) // 权限相关路由
		router.InitRoleRouter(PrivateGroup) // 注册角色路由
		//		router.InitApiRouter(PrivateGroup)                   // 注册功能api路由
		/*		router.InitMenuRouter(PrivateGroup)      // 注册menu路由
				router.InitEmailRouter(PrivateGroup)     // 邮件相关路由
				router.InitSystemRouter(PrivateGroup)    // system相关路由
				router.InitCustomerRouter(PrivateGroup)  // 客户路由
				router.InitAutoCodeRouter(PrivateGroup)  // 创建自动化代码
				router.InitSimpleUploaderRouter(PrivateGroup)        // 断点续传（插件版）
				router.InitSysDictionaryRouter(PrivateGroup)         // 字典管理
				router.InitSysOperationRecordRouter(PrivateGroup)    // 操作记录
				router.InitSysDictionaryDetailRouter(PrivateGroup)   // 字典详情管理
				router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
				router.InitWorkflowProcessRouter(PrivateGroup)       // 工作流相关接口*/
	}

	fmt.Println("router register success")
	return Router
}
